home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 347 < prev    next >
Internet Message Format  |  1996-08-06  |  3KB

  1. Path: solon.com!not-for-mail
  2. From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c.moderated,comp.std.c
  4. Subject: Re: Integral promotion.
  5. Followup-To: comp.std.c
  6. Date: 21 Feb 1996 09:54:38 -0600
  7. Organization: Los Alamos National Laboratory
  8. Sender: clc@solutions.solon.com
  9. Approved: clc@solutions.solon.com
  10. Message-ID: <4gff7u$3cg@solutions.solon.com>
  11. References: <4gf8q7$1bs@solutions.solon.com>
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4gf8q7$1bs@solutions.solon.com> fred@genesis.demon.co.uk
  15. (Lawrence Kirby) writes: 
  16. <snip>
  17.    In article <4g55fl$avl@solutions.solon.com> msb@sq.com  writes:
  18.  
  19.     > > > short test(short x1, short x2) {
  20.     > > >  short result;
  21.     > > >  result = x1 + x2;
  22.     > > 
  23.     > > The addition operator "+" converts your short operands to ints.
  24.     > 
  25.     > No, just using their values does that.  The operator + never sees
  26.     > operands narrower than int.  In the statement
  27.     >         x1; 
  28.     > the short is converted to int before being discarded.
  29.  
  30.    This does however beg a question regarding the standard. Take the
  31.    >> or << operators. In 6.3.7 we have:
  32.  
  33.    "Constraints
  34.  
  35.     Each of the operands shall have integral type
  36.  
  37.     Semantics
  38.  
  39.     The integral promotions are performed on each of the operands..."
  40.  
  41.    If the operator never sees operands narrower than int then this sentence
  42.    is pointless.
  43.  
  44. I initially supported the position advocated by msb@sq.com: 6.2.1.1
  45. states that integral promotions take place whenever an int is
  46. allowed. I still believe it states that, but erroneously ... after
  47. `char x', sizeof x better be sizeof(char) and not necessarily
  48. sizeof(int), even though an int is allowed as an operand of sizeof.
  49.  
  50. I think the footnote needs to be brought into the body of the
  51. standard. I also think that either enums should be prohibited from
  52. being (unsigned) long, or they should be treated somewhat differently
  53. in this clause.
  54.  
  55. In any case, currently, whether an integral promotion takes place
  56. before the value is discarded or not has little bearing on the
  57. behaviour of the program. The topic is quite okay in comp.std.c:
  58. there one is trying to find whether the standard is inconsistent and
  59. it is important to figure out how any change will interact with the
  60. rest of the standard. In c.l.c.m, it is probably not off-topic, but
  61. not very interesting. I have accordingly set follow-up to comp.std.c;
  62. if it survives moderator's software and it is not appropriate, please
  63. change it back.
  64.  
  65. Cheers
  66. Tanmoy
  67. --
  68. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  69. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  70. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  71. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  72. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  73. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  74.